package org.example.controller;


import org.example.domain.Result;
import org.example.domain.UtcItemInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.example.service.IUtcItemInfoService;

/**
 * 内容信息Controller
 *
 * @author coderfun
 * @date 2024-11-24
 */
@RestController
@RequestMapping("/user_to_content/info")
public class UtcItemInfoController   {
    @Autowired
    private IUtcItemInfoService utcItemInfoService;

    /**
     * 查询内容信息列表
     */
//    @GetMapping("/list")
//    public TableDataInfo list(UtcItemInfo utcItemInfo) {
//        startPage();
//        List<UtcItemInfo> list = utcItemInfoService.selectUtcItemInfoList(utcItemInfo);
//        return getDataTable(list);
//    }


    /**
     * 获取内容信息详细信息
     */
    @GetMapping(value = "/{itemId}")
    public Result getInfo(@PathVariable("itemId") Long itemId) {
        return Result.success(utcItemInfoService.selectUtcItemInfoByItemId(itemId));
    }

    /**
     * 新增内容信息
     */

    @PostMapping
    public Result add(@RequestBody UtcItemInfo utcItemInfo) {
        return Result.success(utcItemInfoService.insertUtcItemInfo(utcItemInfo));
    }

    /**
     * 修改内容信息
     */
    @PutMapping
    public Result edit(@RequestBody UtcItemInfo utcItemInfo) {
        return Result.success(utcItemInfoService.updateUtcItemInfo(utcItemInfo));
    }

    /**
     * 删除内容信息
     */
    @PreAuthorize("@ss.hasPermi('user_to_content:info:remove')")
    @DeleteMapping("/{itemIds}")
    public Result remove(@PathVariable Long[] itemIds) {
        return Result.success(utcItemInfoService.deleteUtcItemInfoByItemIds(itemIds));
    }
}
